package com.mdsoft.group.core;
import java.util.ArrayList;
import java.util.List;


public class Group extends ArrayList<People>{
	private static final long serialVersionUID = 7374538308556821408L;
	public Group(List<People> peoples) {
		super(peoples);
	}
	public People goOutPeople() {
		People outPeople = null;
		float minRelation = Float.MAX_VALUE;
		for (People people : this) {
			float relation = checkContentment(people);
			if (minRelation > relation) {
				minRelation = relation;
				outPeople = people;
			}
		}
		remove(outPeople);
		return outPeople;
	}
	public float checkRelation(People people) {
		float relation = 0.0f;
		for (People people2 : this) {
			Choose choose = Context.getInstance().getAllChoose().get(people, people2);
			Choose choose2 = Context.getInstance().getAllChoose().get(people2, people);
			if (choose != null) {
				relation += choose.getPower();
			}
			if (choose2 != null) {
				relation += choose2.getPower();
			}
		}
		return relation;
	}
	
	public float checkContentment(People people) {
		float relation = 0.0f;
		for (People people2 : this) {
			Choose choose = Context.getInstance().getAllChoose().get(people, people2);
			if (choose != null) {
				relation += choose.getPower();
			}			
		}
		return relation;
	}
}
